import { createRouter, createWebHashHistory } from 'vue-router'
import Layout from '@/views/layout/index.vue'
import Login from '@/views/login/index.vue'
// import './permission'

// 静态路由
export const routerData = [
  {
    path: '/login',
    meta: { name: 'login', hidden: true },
    component: Login
  },
  {
    path: '/404',
    name: '404',
    component: () => import('@/views/404.vue'),
    meta: { hidden: true }
  },
  {
    path: '/',
    name: 'layout',
    component: Layout,
    redirect: '/dashboard',
    children: [
      {
        path: '/dashboard',
        name: 'dashboard',
        component: () => import('@/views/dashboard/index'),
        meta: { title: '首页', icon: 'dashboard' }
      }
    ]
  }
]

// 动态路由
export const roleRouterData = [
  {
    path: '/approvals',
    name: 'approvals',
    component: () => import('@/views/approvals/index.vue'),
    meta: { title: '审批', icon: 'tree-table' }
  },
  {
    path: '/departments',
    name: 'departments',
    component: () => import('@/views/departments/index.vue'),
    meta: { title: '组织结构', icon: 'tree' }
  },
  {
    path: '/employees',
    name: 'employees',
    component: () => import('@/views/employees/index.vue'),
    meta: { title: '员工', icon: 'people' }
  },
  {
    path: '/permissions',
    name: 'permissions',
    component: () => import('@/views/permission/index'),
    meta: { title: '权限管理', icon: 'lock' }
  },
  {
    path: '/attendances',
    name: 'attendances',
    component: () => import('@/views/attendances/index.vue'),
    meta: { title: '考勤', icon: 'people' }
  },
  {
    path: '/salarys',
    name: 'salarys',
    component: () => import('@/views/salarys/index.vue'),
    meta: { title: '工资', icon: 'money' }
  },
  {
    path: '/settings',
    name: 'settings',
    component: () => import('@/views/setting/index'),
    meta: { title: '公司设置', icon: 'setting' }
  },
  {
    path: '/social_securitys',
    name: 'social_securitys',
    component: () => import('@/views/social/index.vue'),
    meta: { title: '社保', icon: 'table' }
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes: routerData
})

export default router
